package com.itlong.cloud.tapd.common;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * <des>
 *响应结果格式化
 * <des>
 *
 * @create Date 2021-09-07
 **/
public class Result implements Serializable {

    @Getter
    @Setter
    private Integer status;  //返回的状态。1 代表请求成功，其它代表失败

    @Getter
    @Setter
    private Object data;   //数据部分

    @Getter
    @Setter
    private String info; //	返回说明。如果出错，这里会给出出错信息



    public Result(){
        super();
    }

    /**
     * <desc>
     *      自定义错误码响应结果
     * </desc>
     * @param status
     * @param data
     * @param info
     * @return:
     * @author LiuYu
     * @date:
     **/
    public Result(Integer status,Object data,String info){
        super();
        this.status = status;
        this.data = data;
        this.info = info;
    }

    /**
    * <desc>
    *      成功
    * </desc>
    * @param data
    * @return: com.itlong.cloud.tapd.common.Result
    * @author LiuYu
    * @date: 2021-09-07
     **/
    public static Result success(Object data){
        Result result = new Result();
        result.setStatus(1);
        result.setData(data);
        result.setInfo("success");
        return result;
    }
}
